package com.libreaccess.reporting.utils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

import com.libreaccess.reporting.scheduler.CronTriggerExpr;

public class ReportUtil implements Serializable {

	private static final long serialVersionUID = 1L;

	private long viewId;
	private long timesToExecute;
	private String email;
	private CronTriggerExpr triggerExpr;
	private ReportingEnums.Format reportFormat = ReportingEnums.Format.HTML;
	private String userName;
	private String reportsFolder;
	private HashMap<String, String> parameters;
	private ArrayList<UserLiferay> recipients;
	private String triggerId;
	private long myReportId;
	
	private String url="";
	
	private Date schedulerStartDate = null;
	private long schedulerCountToRun;
	private long schedulerDay;
	private ReportingEnums.SchedulerFrequency schedulerFrequency;
	private String schedulerRecurringDate = "";
	private String schedulerRecurringDatePrefix = null;
	private boolean isCalendarchoosed = true;
	private boolean isSchedulerVisible = false;

	public ReportUtil() {
	};

	public void setParameters(HashMap<String, String> parameters) {
		this.parameters = parameters;
	}
	public HashMap<String, String> getParameters() {
		return parameters;
	}

	public void setViewId(Long viewId) {
		this.viewId = viewId;
	}
	public Long getViewId() {
		return this.viewId;
	}

	public void setReportFormat(ReportingEnums.Format reportFormat) {
		this.reportFormat = reportFormat;
	}
	public ReportingEnums.Format getReportFormat() {
		return this.reportFormat;
	}

	public void setEmail(String email) {
		this.email = email;
	}
	public String getEmail() {
		return this.email;
	}
	
	public void setRecipients(ArrayList<UserLiferay> recipinets) {
		this.recipients = recipinets;
	}
	
	public ArrayList<UserLiferay> getRecipients() {
		return this.recipients;
	}
	
	public void setTriggerExpr(CronTriggerExpr triggerExpr) {
		this.triggerExpr = triggerExpr;
	}
	public CronTriggerExpr getTriggerExpr() {
		if (triggerExpr== null) {
			triggerExpr = new CronTriggerExpr();
		}
		return triggerExpr;
	}
/*
	public void setExpressionTime(String expressionTime) {
		this.expressionTime = expressionTime;
	}
	public String getExpressionTime() {
		return this.expressionTime;
	}*/

	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getUserName() {
		return this.userName;
	}

	public void setTriggerId(String triggerId) {
		this.triggerId = triggerId;
	}
	public String getTriggerId() {
		return triggerId;
	}

	public void setTimesToExecute(long timesToExecute) {
		this.timesToExecute = timesToExecute;
	}
	public long getTimesToExecute() {
		return timesToExecute;
	}

	public Date getSchedulerStartDate() {
		return schedulerStartDate;
	}
	public void setSchedulerStartDate(Date schedulerStartDate) {
		this.schedulerStartDate = schedulerStartDate;
	}

	public long getSchedulerCountToRun() {
		return schedulerCountToRun;
	}
	public void setSchedulerCountToRun(long schedulerCountToRun) {
		this.schedulerCountToRun = schedulerCountToRun;
	}
	
	public ReportingEnums.SchedulerFrequency getSchedulerFrequency() {
		return schedulerFrequency;
	}
	public void setSchedulerFrequency(ReportingEnums.SchedulerFrequency schedulerFrequency) {
		this.schedulerFrequency = schedulerFrequency;
	}
	
	public long getMyReportId() {
		return myReportId;
	}
	public void setMyReportId(long myReportId) {
		this.myReportId = myReportId;
	}
	
	public String getReportsFolder() {
		return reportsFolder;
	}
	public void setReportsFolder(String reportsFolder) {
		this.reportsFolder = reportsFolder;
	}
	
	public long getSchedulerDay() {
		return schedulerDay;
	}
	public void setSchedulerDay(long schedulerDay) {
		this.schedulerDay = schedulerDay;
	}
	
	public String getSchedulerRecurringDate() {
		return schedulerRecurringDate;
	}
	public void setSchedulerRecurringDate(String schedulerRecurringDate) {
		this.schedulerRecurringDate = schedulerRecurringDate;
	}

	public String getSchedulerRecurringDatePrefix() {
		return schedulerRecurringDatePrefix;
	}
	public void setSchedulerRecurringDatePrefix(String schedulerRecurringDatePrefix) {
		this.schedulerRecurringDatePrefix = schedulerRecurringDatePrefix;
	}
	
	public void setIsCalendarchoosed(boolean isCalendarchoosed) {
		this.isCalendarchoosed = isCalendarchoosed;
	}	
	public boolean getIsCalendarchoosed() {
		return isCalendarchoosed;
	}

	public void setSchedulerVisible(boolean isSchedulerVisible) {
		this.isSchedulerVisible = isSchedulerVisible;
	}	
	public boolean getSchedulerVisible() {
		return isSchedulerVisible;
	}
	
	public void setUrl(String url) {
		this.url = url;
	}
	public String getUrl() {
		return url;
	}
	
	public void clearSchedulerData() {
		schedulerFrequency = null;
		schedulerCountToRun = 0l;
		schedulerDay = 0l;
		schedulerStartDate = null;
		isCalendarchoosed = true;
		isSchedulerVisible = false;
		schedulerRecurringDate = "";
//		parameters = null;
		schedulerRecurringDatePrefix = null;
		timesToExecute = 0l;
		triggerExpr = null;
//		myReportId = 0l; do not clear. otherwise trigger won't be removed when count <= 0
		reportFormat = ReportingEnums.Format.HTML;
		email = null;
		recipients = null;
	}

}
